<template>
	<view>
		<goods-choose-list :single="single" :isStock="isStock" :priceType="2" :enterpriseid="enterpriseid" :storeid="storeId" :noPrice="noPrice" :orderId="orderId" :details="details" height="100vh" @confirm="handleConfirm"></goods-choose-list>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				orderId: 0,
				details: [],
				noPrice: false,
				enterpriseid: 0,
				single: false,
				isStock: false
			}
		},
		computed: {
			...mapState({
				userdetail: state => state.userdetail,
				storeId: state => state.storeId
			}),
			...mapState('shop', {
				goodsDetails: state => state.goodsDetails,
			})
		},
		onLoad(options) {
			this.orderId = options.orderId;
			this.noPrice = options.noPrice == 'true'?true:false;
			this.enterpriseid = options.enterpriseid || 0
			this.single = options.single == 'true' ? true:false;
			this.isStock = options.isStock == 'true' ? true:false;
			// 从 Vuex 中读取 details
			this.details = this.goodsDetails;
		},
		methods: {
			setGoodsDetails(data) {
				this.$store.commit('shop/setGoodsDetails', data)
			},
			handleConfirm(confirmForm) {
				// 将 details 存储在 Vuex 中
				this.setGoodsDetails(confirmForm.details);
				uni.navigateBack()
			},
			handleCancel() {
				uni.navigateBack({
					delta: 1,
				});
			},
		}
	}
</script>

<style>

</style>